import { defineConfig } from 'vite'
import vue from '@vitejs/plugin-vue'

// https://vite.dev/config/
export default defineConfig({
  plugins: [vue()],
  optimizeDeps: {
    include: [
      '@kitware/vtk.js/Rendering/OpenGL/**', // 强制包含 OpenGL 后端
      '@kitware/vtk.js/IO/Legacy/**'        // 包含 VTK 文件解析器
    ]
  },
  build: {
    rollupOptions: {
      // 忽略类型检查错误
      onwarn(warning, defaultHandler) {
        if (warning.code === 'SOURCEMAP_ERROR') return
        defaultHandler(warning)
      }
    }
  },
  server: {
    proxy: {
      '/api': {
        target: 'http://127.0.0.1:5000',
        changeOrigin: true,
        rewrite: (path) => path.replace(/^\/api/, '')
      }
    }
  }
})
